package com.betterjr.modules.accountSupervision;

import com.alibaba.dubbo.config.annotation.Reference;
import com.betterjr.common.web.Servlets;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

import static com.betterjr.common.web.ControllerExceptionHandler.exec;

@Controller
@RequestMapping(value = "/Scf/Repayment")
public class ScfRepaymentController {

    private static final Logger logger = LoggerFactory.getLogger(ScfRepaymentController.class);

    @Reference(interfaceClass = IScfRepaymentService.class)
    private IScfRepaymentService scfRepaymentService;

    @RequestMapping(value = "/queryRepayList", method = RequestMethod.POST)
    public @ResponseBody String queryAllRepayment(final HttpServletRequest request,final int flag,final int pageNum, final int pageSize) {
        Map<String, Object> anMap = Servlets.getParametersStartingWith(request, "");
        logger.info("还款监控查询,入参：" + anMap.toString());
        return exec(
                () -> scfRepaymentService.webQueryAllRepayment(anMap,flag,pageNum,pageSize),
                "还款监控查询失败", logger);
    }

    @RequestMapping(value = "/queryBalanceWarnList", method = RequestMethod.POST)
    public @ResponseBody String queryBalanceWarnList(final HttpServletRequest request,final int pageNum, final int pageSize) {
        Map<String, Object> anMap = Servlets.getParametersStartingWith(request, "");
        logger.info("异常事件(余额预警)查询,入参：" + anMap.toString());
        return exec(
                () -> scfRepaymentService.webQueryBalanceWarnList(anMap,pageNum,pageSize),
                "异常事件(余额预警)查询失败", logger);
    }

    @RequestMapping(value = "/queryCapitalWarnList", method = RequestMethod.POST)
    public @ResponseBody String queryCapitalWarnList(final HttpServletRequest request,final int pageNum, final int pageSize) {
        Map<String, Object> anMap = Servlets.getParametersStartingWith(request, "");
        logger.info("异常事件(本金预警)查询,入参：" + anMap.toString());
        return exec(
                () -> scfRepaymentService.webQueryCapitalWarnList(anMap,pageNum,pageSize),
                "异常事件(本金预警)查询失败", logger);
    }

    @RequestMapping(value = "/queryExceptionList", method = RequestMethod.POST)
    public @ResponseBody String queryExceptionList(final HttpServletRequest request,final int pageNum, final int pageSize) {
        Map<String, Object> anMap = Servlets.getParametersStartingWith(request, "");
        logger.info("异常事件(异常交易)查询,入参：" + anMap.toString());
        return exec(
                () -> scfRepaymentService.webQueryExceptionList(anMap,pageNum,pageSize),
                "异常事件(异常交易)查询失败", logger);
    }

    @RequestMapping(value = "/queryAccounBalanceList", method = RequestMethod.POST)
    public @ResponseBody String queryAccounBalanceList(final HttpServletRequest request,final int pageNum, final int pageSize) {
        Map<String, Object> anMap = Servlets.getParametersStartingWith(request, "");
        logger.info("账户查询(余额查询),入参：" + anMap.toString());
        return exec(
                () -> scfRepaymentService.webQueryAccounBalanceList(anMap,pageNum,pageSize),
                "账户查询(余额查询)失败", logger);
    }

    @RequestMapping(value = "/queryAccountCountList", method = RequestMethod.POST)
    public @ResponseBody String queryAccountCountList(final HttpServletRequest request,final int pageNum, final int pageSize) {
        Map<String, Object> anMap = Servlets.getParametersStartingWith(request, "");
        logger.info("账户查询(统计查询),入参：" + anMap.toString());
        return exec(
                () -> scfRepaymentService.webQueryAccounCountList(anMap,pageNum,pageSize),
                "账户查询(统计查询)失败", logger);
    }

    @RequestMapping(value = "/queryAccountStreamList", method = RequestMethod.POST)
    public @ResponseBody String queryAccountStreamList(final HttpServletRequest request,final int pageNum, final int pageSize) {
        Map<String, Object> anMap = Servlets.getParametersStartingWith(request, "");
        logger.info("账户查询(流水查询),入参：" + anMap.toString());
        return exec(
                () -> scfRepaymentService.webQueryAccounStreamList(anMap,pageNum,pageSize),
                "账户查询(流水查询)失败", logger);
    }

}
